package cn.edu.nsmc.modules.sys.controller;

import cn.edu.nsmc.common.utils.PageUtils;
import cn.edu.nsmc.common.utils.R;
import cn.edu.nsmc.modules.sys.entity.SysWorksheetRepairEntity;
import cn.edu.nsmc.modules.sys.service.SysWorksheetRepairService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 维修类工单详情数据
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2024-05-08 09:31:54
 */
@RestController
@RequestMapping("sys/worksheet/repair")
public class SysWorksheetRepairController {
    @Autowired
    private SysWorksheetRepairService sysWorksheetRepairService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:sysworksheetrepair:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysWorksheetRepairService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{worksheetRecordId}")
    // @RequiresPermissions("generator:sysworksheetrepair:info")
    public R info(@PathVariable("worksheetRecordId") Integer worksheetRecordId){
		SysWorksheetRepairEntity sysWorksheetRepair = sysWorksheetRepairService.getById(worksheetRecordId);

        return R.ok().put("sysWorksheetRepair", sysWorksheetRepair);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:sysworksheetrepair:save")
    public R save(@RequestBody SysWorksheetRepairEntity sysWorksheetRepair){
		sysWorksheetRepairService.save(sysWorksheetRepair);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:sysworksheetrepair:update")
    public R update(@RequestBody SysWorksheetRepairEntity sysWorksheetRepair){
		sysWorksheetRepairService.updateById(sysWorksheetRepair);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:sysworksheetrepair:delete")
    public R delete(@RequestBody Integer[] worksheetRecordIds){
		sysWorksheetRepairService.removeByIds(Arrays.asList(worksheetRecordIds));

        return R.ok();
    }

}
